package com.hmdp.controller;

import com.hmdp.utils.MailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mail")
public class MailController {

    @Autowired
    private MailUtils mailUtils;
    static String emailAddr = "2876271031@qq.com";



    /**
     * 发送注册验证码
     * @return 验证码
     * @throws Exception
     */
//    @ApiOperation("发送注册验证码")
    @GetMapping("/testMail")
    public String send(){
        mailUtils.sendSimpleMail(emailAddr,"普通文本邮件","普通文本邮件内容");
        return "OK";
    }

    /**
     * 发送注册验证码
     * @return 验证码
     * @throws Exception
     */
//    @ApiOperation("发送注册验证码")
    @PostMapping("/sendHtml")
    public String sendTemplateMail(){
        mailUtils.sendHtmlMail(emailAddr,"一封html测试邮件",
                "<div style=\"text-align: center;position: absolute;\" >\n"
                        +"<h3>\"一封html测试邮件\"</h3>\n"
                        + "<div>一封html测试邮件</div>\n"
                        + "</div>");
        return "OK";
    }

//    @ApiOperation("发送html模板邮件")
    @PostMapping("/sendTemplate")
    public String sendTemplate(){
        mailUtils.sendTemplateMail(emailAddr, "基于模板的html邮件", "hello.html");
        return "OK";
    }

//    @ApiOperation("发送带附件的邮件")
    @GetMapping("sendAttachmentsMail")
    public String sendAttachmentsMail(){
        String filePath = "C:\\Users\\Kirito\\Desktop\\壁纸\\test.png";
        mailUtils.sendAttachmentsMail(emailAddr, "带附件的邮件", "邮件中有附件", filePath);
        return "OK";
    }
}